import React, { memo } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import {changeOne,del} from "../store/goods"
const List = memo(() => {
  const List = useSelector(state => state.goods.newList)
  const dispatch = useDispatch()
  return (
    <div className='list'>
       <ul>
        {List.map((item)=>(
          <li key={item.id}>
            <input type="checkbox" checked={item.isDone} onChange={()=>{
              dispatch(changeOne(item.id))
            }}/>
            {item.desc}
            <span onClick={()=>{dispatch(del(item.id))}}>
              删除
            </span>
          </li>
        ))}
       </ul>
    </div>
  )
})

export default List